﻿@model RielAp.Web.Models.LandFilterCriteriaViewModel

@using (Html.BeginForm(new { considerEmpty=false}))
{
    if (!Html.ViewData.ModelState.IsValid)
        {
        <div class="alert alert-error">
            @foreach (var modelError in Html.ViewData.ModelState.SelectMany(keyValuePair => keyValuePair.Value.Errors))
            {
                <div>@modelError.ErrorMessage</div>
            }
        </div>
        }
    <div class="well sidebar-nav">
        <ul class="nav nav-list">
            <li class="nav-header">Фільтр</li>

            <li class="row-fluid">
                <div class="span5" style="line-height: 30px;">Адреса:</div>
                @Html.DropDownListFor(m => m.Filter.Address.AddressType, Model.AddressTypes, new { @class = "span7", id = "AddressType" })
            </li>
            <li class="row-fluid villarge-address address">
                <div class="span5" style="line-height: 30px;">Область:</div>
                <select id="AdministrativeArea" disabled="true"  name="Filter.Address.AdministrativeArea" class="span7"></select>
            </li>

            <li class="row-fluid villarge-address address">
                <div class="span5" style="line-height: 30px;">Район:</div>
                <select id="SubAdministrativeArea" disabled="true" name="Filter.Address.SubAdministrativeArea" class="span7"></select>
            </li>

            <li class="row-fluid address">
                <div class="span5" style="line-height: 30px;">Населений пункт:</div>
                <select id="LocalityNames" disabled="true" name="Filter.Address.LocalityName" class="span7"></select>
            </li>

            <li class="row-fluid city-address address">
                <div class="span5" style="line-height: 30px;">Район міста:</div>
                <select id="Districts" disabled="true" name="Filter.Address.District" class="span7"></select>

            </li>

            <li class="divider"></li>
            <li class="row-fluid">
                <div class="span5" style="line-height: 30px;">@RielAp.Translation.Translation.LandsDetailsPageApplyTypeLabel:</div>
                @Html.DropDownListFor(m => m.Filter.ApplyType, Model.ApplyTypes, new { @class = "span7" })
            </li>
            <li class="divider"></li>

            <li>Ціна:</li>
            <li class="row-fluid">
                @Html.TextBoxFor(m => m.Filter.StartPrice, new {@class="span4", placeholder="від"})
                @Html.TextBoxFor(m => m.Filter.EndPrice, new {@class="span4", placeholder="до"})
                @Html.DropDownListFor(m=>m.Filter.Currency, Model.Currencies, new {@class="span4"})
            </li>
            <li class="divider"></li>
            <li>Площа:</li>
            <li class="row-fluid">
                @Html.TextBoxFor(m => m.Filter.StartTotalSquare, new {@class="span4", placeholder="від"})
                @Html.TextBoxFor(m => m.Filter.EndTotalSquare, new {@class="span4", placeholder="до"})
                @Html.DropDownListFor(m=>m.Filter.TotalSquareUnit, Model.SquareUnits, new {@class="span4"})
            </li>
            <li class="divider"></li>
            <li class="row-fluid">
                <button type="submit" class="btn btn-primary span12"><i class="icon-search icon-white"></i>Показати</button>
            </li>
            <li class="divider"></li>
            @if (Model.Filter.IsNotEmpty())
            {
                <li class="row-fluid">
                    <div>
                        <a class="btn btn-danger span12" href="@Url.Action("ClearLandFilter", new {type = ViewBag.Type, viewtype = ViewBag.ViewType})">Стерти фільтр</a>
                    </div>
                </li>
            }

        </ul>
    </div>
}
    
<script type="text/javascript">
    $(document).ready(function () {
        var addressFilter = new AddressFilter("@Url.Action("GetLandsAdministrativeAreas", "Address")", "@Url.Action("GetLandsSubAdministrativeAreas", "Address")", "@Url.Action("GetLandsLocalities", "Address")", "@Url.Action("GetLandsDistricts", "Address")")
        addressFilter.init("@Model.Filter.Address.AddressType", "@Model.Filter.Address.AdministrativeArea", "@Model.Filter.Address.SubAdministrativeArea", "@Model.Filter.Address.LocalityName", "@Model.Filter.Address.District");
    });
</script>